var app = getApp();
Page({
  data: {
    router_filed: '',
    fr2ssid: '',
    fr5ssid: '',
    name: [],
    length:'',
    display: 'none'
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
     var that = this;
    //var list=[];
    wx.request({
      url: 'https://cd.tunnel.litelink.me/v1/smallapp/querySSID',
      data:{
        deviceid:app.globalData.deviceid
      },
      method: 'GET',
      header: {
        "Content-Type": "application/json"
      },
      success: function (res) {
        console.log(res);
        console.log(res.data.length);
        
        
        let j = 0;
        for (let i = 0; i < res.data.length; ++i) {

          if (res.data[i] != "") {
            console.log("test")
            that.data.name[j] = { "name": res.data[i] };
            j = j + 1;
          }
        }
        that.setData({
          length:j,
          name:that.data.name
        })
      },

    });
     wx.showToast({
      title: '正在加载',
      icon: 'loading',
      duration: 3000
    })

  },
  onReady: function () {
    // 页面渲染完成

  },
  onShow: function () {
   
    // 页面显示
    this.setData({
      fr2ssid: app.globalData.fr2ssid,
      fr5ssid: app.globalData.fr5ssid,
    })

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭

  },
  back: function () {
    console.log("back");
    wx.navigateBack({
      delta: 1
    });
  },
  add_router: function () {
    console.log(this.data.length);
    if(this.data.length == 2){
      wx.showToast({
          title: '只能添加两个',
          duration: 2000
      })
      return
    }
    console.log("add_router");
    wx.navigateTo({
      url: "../add_router/add_router"

    });
  },
  GHz2_set: function () {
    console.log("GHz2_set");
    wx.navigateTo({
      url: "../GHz2_set/GHz2_set"

    });
  },
  GHz5_set: function (event) {
    console.log(event.target.dataset);
    console.log("GHz5_set");
    // wx.navigateTo({
    //     url:"../GHz5_set/GHz5_set"

    // });
  }
})